NET Generational Garbage Collection (GC) Deep Dive

1 min read
Senior1 min read
Rapid overview

NET Generational Garbage Collection (GC) Deep Dive

TL;DR

JavaScript engines use generational GC to optimize for short-lived objects.

Why it matters

  • Excess allocations in render loops increase GC pressure.
  • Long-lived caches grow old space and cause longer pauses.

How it works


Generations

  • Young space: New allocations, collected frequently.
  • Old space: Promoted objects that survive collections.

Practical guidance

  • Reuse objects in hot loops.
  • Avoid holding large arrays in global state without limits.
  • Clear timers and listeners when components unmount.

Interview prompt

  • Explain how you reduce GC pressure in UI rendering.

See also